Skip to main content

Edit Laravel Route

  • Open routes/web.php file.

    Create React Build

  • You have to change / route to this /admin.

       Route::get('/', [LoginController::class, 'index'])->name('login');
       Route::get('/admin', [LoginController::class, 'index'])->name('login');
    • So from now on, you have to access your admin panel from http://your_server_ip/admin.
  • Add this code at the end of the file so that it can serve your website.

    // Catch all non-API routes and serve React app
    Route::get('/{any}', function () {
    return response()->file(public_path('react/index.html')); // Serve React's index.html directly
    })->where('any', '^(?!api).*');
    Edit file:
    • While editing file: Make sure you only add this code at the end of the file.
    • Otherwise, it could stop your backend api from working.
    • You have to access your website from http://your_server_ip/ route.